#include "curva.h"

//Curva::Curva(QGraphicsScene &s) : myScene(s), _plotColor(Qt::black)
Curva::Curva(void) : _plotColor(Qt::black), MAX_STEPS (32)
{
}

QPointF Curva::readPoint(QDomElement p)
{
	QDomElement coords = p.firstChildElement();

	QPointF point;

	while( !coords.isNull())
	{
		if( coords.tagName() == "x")
		{
			QString t = coords.text();
			point.setX(t.toDouble());
		}
		else if( coords.tagName() == "y" )
		{
			QString t = coords.text();
			point.setY(t.toDouble());
		}
		else
		{
			qDebug() << "\t" <<  "Unknow Tag name " << coords.tagName() << " inside \"" << p.tagName() << "\" Tag";
		}
		coords = coords.nextSiblingElement();
	}

	return point;
}

QColor Curva::readColor(QDomElement e)
{
	QColor c;

	QDomElement cores = e.firstChildElement();

	while( !cores.isNull() )
	{
		if( cores.tagName() == "r")
		{
			QString t = cores.text();
			c.setRed(t.toInt());
		}
		else if( cores.tagName() == "g" )
		{
			QString t = cores.text();
			c.setGreen(t.toInt());
		}
		else if( cores.tagName() == "b" )
		{
			QString t = cores.text();
			c.setBlue(t.toInt());
		}
		else
		{
			qDebug() << "\t" <<  "Unknow Tag name " << cores.tagName() << " inside \"" << e.tagName() << "\" Tag";
		}
		cores = cores.nextSiblingElement();
	}

	return c;
}
